﻿using Leeder.Logger;
using NewAndong.Business;
using NewAndong.Comm;
using NewAndong.Model;
using Sunny.UI;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NewAndong.Forms
{
    public partial class FrmTransportSet : UIPage
    {
        bool isLoad = true;
        AutoSizeFormClass asc = new AutoSizeFormClass();
        public LogOperate LogObj => Log.GetLogger(this.GetType());

        DirectQuoteBLL bllDirectQuote = new DirectQuoteBLL();

        public FrmTransportSet()
        {
            InitializeComponent();
        }

        private void FrmTransportSet_Load(object sender, EventArgs e)
        {
            if (!isLoad)
                return;
            isLoad = false;

            Init_Control();
        }

        private void Init_Control()
        {
            var list = bllDirectQuote.GetModelList();
            foreach (var item in list)
            {
                item.UseStatus = item.IsUse == 0 ? "未启用" : "已启用";
                item.TypeName = item.Type == "SY" ? "顺引" : "出发链";
            }
            var cflUseList = list.Where(w => w.Type == "CFL" && w.IsUse == 1).ToList();
            //加载顺引页面
            for (int i = 0; i < cflUseList.Count(); i++)
            {
                FrmTransport frmTransport = new FrmTransport(cflUseList[i].DirectName);
                tabControl.AddPage(frmTransport);
                tabControl.TabPages[i].Text = cflUseList[i].DirectName;
            }
        }
    }
}
